/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hitechbangla.fctu.form;

import fctu.simulator.HTB_MAIN;
import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.CheckboxMenuItem;
import java.awt.GridLayout;
import javax.swing.BoxLayout;
import com.hitechbangla.fctu.base.aircraft.*;
import com.hitechbangla.fctu.utility.enumall.AircraftIdentity;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JCheckBox;

/**
 *
 * @author ASUS
 */
public class AircraftColor extends javax.swing.JFrame {
    JCheckBox c1;
    JCheckBox c2;
    JCheckBox c3;
    JCheckBox c4;
    JCheckBox c5;
    JCheckBox c6;
    public String callsign = "0";
    public String name = "0";
    /**
     * Creates new form AircraftColor
     */
    public AircraftColor(HTB_MAIN htb_main) {
        this.setTitle("Aircraft Color");
        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        this.setResizable(false);
        
        /*setLayout(new GridLayout(3, 1));
        CheckboxGroup cbg = new CheckboxGroup();
    this.add(new Checkbox("Hostile", cbg, true));
    this.add(new Checkbox("X-Raid", cbg, false));
    this.add(new Checkbox("Target", cbg, false));
    this.add(new Checkbox("Interceptor", cbg, false));
   // this.add(new Checkbox("Cash", cbg, true));*/ // the default
        
   
        
        initComponents();
          ShowClick();
          selectColorPosition();
          combo_data();
          init();      
    
    }
    public AircraftColor()
    {
        
    }
    public void ShowClick()
    {
        
        //setLayout(new GridLayout(7,1));
        //setLayout(new BoxLayout(, 7));
        //setBounds(10, 10, 10, 10);
        //CheckboxGroup cbg = new CheckboxGroup();
        
       c1 = new JCheckBox("Hostile",false);
       c2 = new JCheckBox("X-Raid",false);
       c3 = new JCheckBox("Target",false);
       c4 = new JCheckBox("Interceptor",false);
       c5 = new JCheckBox("Allied",false);
       c6 = new JCheckBox("Bomber",false);
              
         add(c1);
         add(c2);
         add(c3);
         add(c4);
         add(c5);
         add(c6);
    }

    public void init()
    {
        c1.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
                trace("1", c1);
                if(c1.isSelected())
                {
                    c2.setSelected(false);
                    c3.setSelected(false);
                    c4.setSelected(false);
                    c5.setSelected(false);
                    c6.setSelected(false);
                }
                //c1.getName();
                ////System.out.println(c1.getLabel());
                HTB_MAIN.gameScene.airCraftList.get(jComboBox1.getSelectedIndex()).getAircraftState().setAircraftIdentity(AircraftIdentity.hostile);
                
                
                name = c1.getLabel().toString();
                callsign = jComboBox1.getSelectedItem().toString();
                ////System.out.println(jComboBox1.getSelectedItem().toString());
               // Graphics2D g2d;
                
                
            }
        });
        
            c2.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
                trace("1", c2);
               // c2.setEnabled(false);
                  if(c2.isSelected())
                {
                    
                    c1.setSelected(false);
                    c3.setSelected(false);
                    c4.setSelected(false);
                    c5.setSelected(false);
                    c6.setSelected(false);
                }
                  
            HTB_MAIN.gameScene.airCraftList.get(jComboBox1.getSelectedIndex()).getAircraftState().setAircraftIdentity(AircraftIdentity.xraid);
                //c2.disable();
                name = c2.getLabel().toString();
                callsign = jComboBox1.getSelectedItem().toString();
            }
        });
        
        c3.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
                trace("1", c3);
                //c3.setEnabled();
                if(c3.isSelected())
                {
                    
                    c1.setSelected(false);
                    c2.setSelected(false);
                    c4.setSelected(false);
                    c5.setSelected(false);
                    c6.setSelected(false);
                }
                HTB_MAIN.gameScene.airCraftList.get(jComboBox1.getSelectedIndex()).getAircraftState().setAircraftIdentity(AircraftIdentity.target);
                name = c3.getLabel().toString();
                callsign = jComboBox1.getSelectedItem().toString();
            }
        });
        
        c4.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
                trace("1", c4);
                if(c4.isSelected())
                {
                    
                    c1.setSelected(false);
                    c2.setSelected(false);
                    c3.setSelected(false);
                    c5.setSelected(false);
                    c6.setSelected(false);
                }
                HTB_MAIN.gameScene.airCraftList.get(jComboBox1.getSelectedIndex()).getAircraftState().setAircraftIdentity(AircraftIdentity.interceptor);
                name = c4.getLabel().toString();
                callsign = jComboBox1.getSelectedItem().toString();
            }
        });
        
        c5.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
                trace("1", c5);
                if(c5.isSelected())
                {
                    
                    c1.setSelected(false);
                    c2.setSelected(false);
                    c3.setSelected(false);
                    c4.setSelected(false);
                }
                HTB_MAIN.gameScene.airCraftList.get(jComboBox1.getSelectedIndex()).getAircraftState().setAircraftIdentity(AircraftIdentity.allied);
                name = c5.getLabel().toString();
                callsign = jComboBox1.getSelectedItem().toString();
            }
        });
        
        c6.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
               // throw new UnsupportedOperationException("Not supported yet.");
                trace("1", c6);
                if(c6.isSelected())
                {
                    
                    c1.setSelected(false);
                    c2.setSelected(false);
                    c3.setSelected(false);
                    c4.setSelected(false);
                    c5.setSelected(false);
                }
                HTB_MAIN.gameScene.airCraftList.get(jComboBox1.getSelectedIndex()).getAircraftState().setAircraftIdentity(AircraftIdentity.bomber);
                name = c6.getLabel().toString();
                callsign = jComboBox1.getSelectedItem().toString();
            }
        });
        
        
    }
    
         private void selectColorPosition()
         {
            int y = 65;
            int x = 50;
            Dimension dimension = c1.getPreferredSize(); 	    
            c1.setBounds(x, y , dimension.width, dimension.height);	    
            y+=40;

            y = 90;
            x = 50;
            dimension = c2.getPreferredSize(); 	    
            c2.setBounds(x, y , dimension.width, dimension.height);	    
            y+=40;

            y = 115;
            x = 50;
            dimension = c3.getPreferredSize(); 	    
            c3.setBounds(x, y , dimension.width, dimension.height);	    
            y+=40;

            y = 140;
            x = 50;
            dimension = c4.getPreferredSize(); 	    
            c4.setBounds(x, y , dimension.width, dimension.height);	    
            y+=40;
            
            y = 165;
            x = 50;
            dimension = c5.getPreferredSize(); 	    
            c5.setBounds(x, y , dimension.width, dimension.height);	    
            y+=40;
            
            y = 190;
            x = 50;
            dimension = c6.getPreferredSize(); 	    
            c6.setBounds(x, y , dimension.width, dimension.height);	    
            y+=40;

         
     
        }
    
   
    public void trace(String str, JCheckBox checkbox)
    {
//       if(checkbox.isSelected())
//       {
//           System.out.println("Color is selected");
//       }
//       else
           //System.out.println("Color is not selected");
    }
    
    public void combo_data()
    {
       for(int i=0;i<HTB_MAIN.gameScene.airCraftList.size();i++)
       {
           
       jComboBox1.addItem(HTB_MAIN.gameScene.airCraftList.get(i).getAircraftState().getCallSign());
       }
      
    
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jComboBox1 = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(200, 250));

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] {}));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        jLabel1.setText("CallSign");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(118, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addContainerGap(208, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        // TODO add your handling code here:
        
    }//GEN-LAST:event_jComboBox1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AircraftColor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AircraftColor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AircraftColor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AircraftColor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new AircraftColor(null).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables
}
